import os

import pymysql
import pytest

from config.config import *


@pytest.fixture(scope="session", autouse=True)
def destroy_data():
    yield
    sqls = [
        SQL1
    ]
    conn = pymysql.Connect(
        # host=DB_HOST,
        # port=DB_PORT,
        # database=DB_NAME,
        # user=DB_USER,
        # password=DB_PASSWORD,
        # charset=
        **eval(os.environ["DB"]),
        autocommit=True
    )
    # 3，创建游标-驴
    cur = conn.cursor()
    for sql in sqls:
        cur.execute(sql)
    # 5，关闭游标
    cur.close()
    # 6，关闭连接
    conn.close()
